package mvn56.model;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component("annoteUser")
public class User {
	
	public User() {}
	
	public User(String myname,int myage) {
		this.name = myname;
		this.age = myage;
	}
	
	public User(String myname,int myage,Address myaddress) {
		this.name = myname;
		this.age = myage;
		this.address =myaddress;
	}
	
	@Value("${myuser.name}")
	private String name;
	@Value("${myuser.age}")
	private int age;
	
	//@Autowired  //按照类型进行注入
	//@Qualifier("mySecAddress") //设置按照名字进行注入
	@Resource(name="mySecAddress") //设置按照名字进行注入
	private Address address;

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	public void showInfo() {
		System.out.println("用户名："+name+",age="+age);
		System.out.println("地址："+this.address.getCity());
	}

	public int getAge() {
		return age;
	}

	public void setAge(int age) {
		this.age = age;
	}

	public Address getAddress() {
		return address;
	}

	public void setAddress(Address address) {
		this.address = address;
	}

}
